/**
 * Copyright 2012 Fonfon.Xen
 * All rights reserved.
 * 
 * @project 
 * @author Xen
 * @version 1.0
 * @data 2012-5-17
 */
package com.guidecaptain.java.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.guidecaptain.java.mapper.ConstellationMapper;
import com.guidecaptain.java.model.pojo.Constellation;
import com.guidecaptain.java.service.ConstellationService;

/**
 * @author Xen
 *
 */
@Service("constellationService")
public class ConstellationServiceImpl implements ConstellationService{
	
	@Autowired
	private ConstellationMapper constellationMapper;
	/**
	 * @param 
	 * @return  
	 */
	@Override
	public int insertConstellation(Constellation constellation) {
		constellationMapper.insertConstellation(constellation);
		return constellation.getCslId();
	}

	/**
	 * @param 
	 * @return  
	 */
	@Override
	public int deleteConstellation(int cslId) {
		
		return 0;
	}

	/**
	 * @param 
	 * @return  
	 */
	@Override
	public int updateConstellation(Constellation constellation) {
		
		return constellationMapper.updateConstellation(constellation);
	}

	/**
	 * @param 
	 * @return  
	 */
	@Override
	public List<Constellation> queryConstellationList(Constellation constellation) {
		
		return constellationMapper.queryConstellation(constellation);
	}

	/**
	 * @param 
	 * @return  
	 */
	@Override
	public Constellation queryConstellationById(int cslId) {
		Constellation constellation=new Constellation();
		constellation.setCslId(cslId);
		List<Constellation> constellations=constellationMapper.queryConstellation(constellation);
		return (constellations.size()>0)?constellations.get(0):null;
	}

	/**
	 * @param 
	 * @return  
	 */
	@Override
	public boolean checkCslType(String cslType) {
		Constellation constellation=new Constellation();
		constellation.setCslType(cslType);
		List<Constellation> constellations=constellationMapper.queryConstellation(constellation);
		return (constellations.size()>0)?true:false;
	}

}
